/**
 * Licensee: Anonymous
 * License Type: Purchased
 */
package ormsamples;

import org.orm.*;
public class DeleteEstateData {
	public void deleteTestData() throws PersistentException {
		PersistentTransaction t = com.estate.datalogic.EstatePersistentManager.instance().getSession().beginTransaction();
		try {
			com.estate.datalogic.DAOFactory lDAOFactory = com.estate.datalogic.DAOFactory.getDAOFactory();
			com.estate.datalogic.dao.Ad_typeDAO lcomestatedatalogicAd_typeDAO = lDAOFactory.getAd_typeDAO();
			com.estate.datalogic.Ad_type lcomestatedatalogicAd_type = lcomestatedatalogicAd_typeDAO.loadAd_typeByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicAd_typeDAO.delete(lcomestatedatalogicAd_type);
			com.estate.datalogic.dao.AdvertisementDAO lcomestatedatalogicAdvertisementDAO = lDAOFactory.getAdvertisementDAO();
			com.estate.datalogic.Advertisement lcomestatedatalogicAdvertisement = lcomestatedatalogicAdvertisementDAO.loadAdvertisementByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicAdvertisementDAO.delete(lcomestatedatalogicAdvertisement);
			com.estate.datalogic.dao.ClientDAO lcomestatedatalogicClientDAO = lDAOFactory.getClientDAO();
			com.estate.datalogic.Client lcomestatedatalogicClient = lcomestatedatalogicClientDAO.loadClientByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicClientDAO.delete(lcomestatedatalogicClient);
			com.estate.datalogic.dao.CountyDAO lcomestatedatalogicCountyDAO = lDAOFactory.getCountyDAO();
			com.estate.datalogic.County lcomestatedatalogicCounty = lcomestatedatalogicCountyDAO.loadCountyByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicCountyDAO.delete(lcomestatedatalogicCounty);
			com.estate.datalogic.dao.CountryDAO lcomestatedatalogicCountryDAO = lDAOFactory.getCountryDAO();
			com.estate.datalogic.Country lcomestatedatalogicCountry = lcomestatedatalogicCountryDAO.loadCountryByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicCountryDAO.delete(lcomestatedatalogicCountry);
			com.estate.datalogic.dao.TownDAO lcomestatedatalogicTownDAO = lDAOFactory.getTownDAO();
			com.estate.datalogic.Town lcomestatedatalogicTown = lcomestatedatalogicTownDAO.loadTownByQuery(null, null);
			// Delete the persistent object
			lcomestatedatalogicTownDAO.delete(lcomestatedatalogicTown);
			t.commit();
		}
		catch (Exception e) {
			t.rollback();
		}
		
	}
	
	public static void main(String[] args) {
		try {
			DeleteEstateData deleteEstateData = new DeleteEstateData();
			try {
				deleteEstateData.deleteTestData();
			}
			finally {
				com.estate.datalogic.EstatePersistentManager.instance().disposePersistentManager();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
